package objekte;

public class PersonenTest {
  public static void main(String[] args) {
    Person[] p = new Person[10];
    for (int i = 0; i < 10; ++i) {
      int len1 = (int)(Math.random() * 5) + 2;
      int len2 = (int)(Math.random() * 5) + 2;
      char[] name = new char[len1];
      char[] vorname = new char[len2];
      name[0] = (char)(Math.random() * 26 + 'A');
      vorname[0] = (char)(Math.random() * 26 + 'A');
      for (int j = 1; j < len1; ++j)
        name[j] = (char)(Math.random() * 26 + 'a');
      for (int j = 1; j < len2; ++j)
        vorname[j] = (char)(Math.random() * 26 + 'a');
      boolean maennlich = Math.random() < 0.5;
      p[i] = new Person(String.valueOf(vorname), String.valueOf(name), maennlich);
      System.out.println("Die " + i + ". Person heißt " + p[i].name +
          " und ist " + (p[i].mann ? "männlich." : "weiblich."));
    }
    System.out.println();
    for (int i = 0; i < 5; ++i) {
      int h1 = (int)(Math.random() * 10);
      int h2;
      do h2 = (int)(Math.random() * 10); while (h2 == h1);
      System.out.println("Die Heirat zwischen " + p[h1].name + " und " +
          p[h2].name + (p[h1].heirate(p[h2]) ? " war erfolgreich." :
            " war nicht möglich."));
    }
    System.out.println();
    System.out.println("Auflistung der Personen");
    System.out.println("=======================");
    System.out.println();
    Person.ausgabe(p);
  }
}
